﻿using LeaRun.Application.Busines.BaseManage;
using LeaRun.Application.Entity.BaseManage;
using LeaRun.Util;
using LeaRun.Util.WebControl;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.Mvc;
namespace LeaRun.Application.Web.Areas.BaseManage.Controllers
{
    public class studentController : MvcControllerBase
    {
        private studentBLL studentbll = new studentBLL();
        [HttpGet]
        public ActionResult studentIndex()
        {
            return base.View();
        }
        [HttpGet]
        public ActionResult studentForm()
        {
            return base.View();
        }
        [HttpGet]
        public ActionResult GetPageListJson(Pagination pagination, string queryJson)
        {
            Stopwatch watch = CommonHelper.TimerStart();
            var data = new
            {
                rows = this.studentbll.GetPageList(pagination, queryJson),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records,
                costtime = CommonHelper.TimerEnd(watch)
            };
            return this.ToJsonResult(data);
        }
        [HttpGet]
        public ActionResult GetListJson(string queryJson)
        {
            IEnumerable<studentEntity> list = this.studentbll.GetList(queryJson);
            return this.ToJsonResult(list);
        }
        [HttpGet]
        public ActionResult GetFormJson(string keyValue)
        {
            studentEntity entity = this.studentbll.GetEntity(keyValue);
            return this.ToJsonResult(entity);
        }
        [AjaxOnly(false), HttpPost, ValidateAntiForgeryToken]
        public ActionResult RemoveForm(string keyValue)
        {
            this.studentbll.RemoveForm(keyValue);
            return this.Success("删除成功。");
        }
        [AjaxOnly(false), HttpPost, ValidateAntiForgeryToken]
        public ActionResult SaveForm(string keyValue, studentEntity entity)
        {
            this.studentbll.SaveForm(keyValue, entity);
            return this.Success("操作成功。");
        }
    }
}
